package com.itic.market.system.synctgw.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.itic.appbase.framework.common.constants.DBConst;
import com.itic.appbase.framework.common.service.CrudService;
import com.itic.market.system.synctgw.persistence.model.SyncTgwExample.Criteria;
import com.itic.market.system.synctgw.persistence.dao.SyncTgwDao;
import com.itic.market.system.synctgw.persistence.model.SyncTgw;
import com.itic.market.system.synctgw.persistence.model.SyncTgwExample;


@Service
@Transactional
public class SyncTgwService
     extends CrudService<SyncTgwDao,SyncTgw,SyncTgwExample> {
    @Autowired
    private SyncTgwDao syncTgwDao;

	public SyncTgw getByTgwName(String tgwName) {
		return syncTgwDao.getByTgwName(tgwName);
	}

	public String getTgwidByUserid(String userid) {
		String result = "";
		SyncTgwExample example = new SyncTgwExample();
		Criteria criteria = example.createCriteria();
		criteria.andIsEffectiveEqualTo(DBConst.TRUE);
		criteria.andUserIdEqualTo(userid);
		List<SyncTgw> list = syncTgwDao.selectByExample(example);
		if( list.size()>0 ){
			SyncTgw syncTgw = list.get(0);
			result = syncTgw.getTgwId();
		}
		return result;
	}


}